package com.brother.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;

import com.brother.database.DataBase;

public class ContentProperties {

	
	private static 	Properties props = null;
	static{
		if(props == null) {
			InputStream in = DataBase.class.getResourceAsStream("/message.properties");
			props = new Properties();
			try {
				props.load(in);
			} catch (IOException e) {
				
			}finally {
				if(in != null)
					try {
						in.close();
					} catch (IOException e) {
						
					}
			}
		}	
	}
	
	private static 	Properties zhProps = null;
	private static 	Properties ptProps = null;
	static{
		if(zhProps == null) {
			InputStream in = DataBase.class.getResourceAsStream("/message_zh.properties");
			zhProps = new Properties();
			try {
				zhProps.load(in);
			} catch (IOException e) {
				
			}finally {
				if(in != null)
					try {
						in.close();
					} catch (IOException e) {
						
					}
			}
		}
		if(ptProps == null){
			InputStream in = DataBase.class.getResourceAsStream("/message_pt.properties");
			ptProps = new Properties();
			try {
				ptProps.load(in);
			} catch (IOException e) {
				
			}finally {
				if(in != null)
					try {
						in.close();
					} catch (IOException e) {
						
					}
			}
		}
	}
	

	public static String getProperty(String key, String language){
		if("pt".equalsIgnoreCase(language) && ptProps.containsKey(key))
			return ptProps.getProperty(key);
		else if("zh".equalsIgnoreCase(language)  && zhProps.containsKey(key))
			return zhProps.getProperty(key);
		else
			return props.getProperty(key);
	}
}
